package com.mice.springbootmodel.web;


import com.mice.springbootmodel.common.Result;
import com.mice.springbootmodel.domain.bean.UserBean;
import com.mice.springbootmodel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author: ChenHao
 * @Date: 2018/5/22 17:36
 */

@Controller
public class TestController {

    @Autowired
    UserService userService;

    @RequestMapping("insert")
    @ResponseBody public Result test(String userName){
        UserBean userBean = new UserBean();
        userBean.setUserName(userName);
        userService.insertOne(userBean);
        return Result.success();
    }

    @RequestMapping("get")
    @ResponseBody public Result test(Long userId){
        UserBean user = userService.getOne(userId);
        return Result.success(user);
    }
}
